
window.onload = function() {
	var select = document.getElementById('term');

		select[0]=new Option(getTerm(1),getTerm(1));
		select[1]=new Option(getTerm(0),getTerm(0));
		select[2]=new Option(getTerm(2),getTerm(2));
		select[3]=new Option(getTerm(3),getTerm(3));

};

/*function syllabusFindBySid2(term){
	var result = getUrl(); 
    window.parent.body.location.href=result+"/syllabus/findBySid2?term="+term;  		

}*/

function courseFindAll(term){
	var result = getUrl(); 
    window.parent.body.location.href=result+"/course/findAll?term="+term;
}

function getTerm(i){
	var date = new Date();
	var year = date.getFullYear();
	var mouth = date.getMonth()+1;
	var term;
	if(mouth >= 9 || mouth <= 2) {
		if(mouth >=9){
			if(i == 0){
				term = year+"02";
			}
			else if (i == 1){
				term = year+"01";
			}
			else if (i == 2){
				term = year-1+"02";
			}
			else if (i == 3){
				term = year-1+"01";
			}
		}else{
			if(i == 0){
				term = year-1+"02";
			}
			else if (i == 1){
				term = year-1+"01";
			}
			else if (i == 2){
				term = year-2+"02";
			}
			else if (i == 3){
				term = year-2+"01";
			}
		}
	}else {
		if(i == 0){
			term = year+"01";
		}
		else if (i == 1){
			term = year-1+"02";
		}
		else if (i == 2){
			term = year-1+"01";
		}
		else if (i == 3){
			term = year-2+"02";
		}
	}
	return term;
}

function getRealTerm(){
	var date = new Date();
	var year = date.getFullYear();
	var mouth = date.getMonth()+1;
	var realterm;
	if(mouth >= 9 || mouth <= 2) {
		if(mouth >=9){
			realterm = year+"01";
		}else{
			realterm = year-1+"01";
		}
	}else {
		realterm = year-1+"02";
	}
	return realterm;
};
//1
function getUrl()
{
	//var pageContext = document.getElementById("PageContext").value;
	
	var pathName = document.location.pathname;
//	alert(pathName);
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
//    alert(result);
    return result;
}

function select(cid,term)
{
//	alert(1);
	var result = getUrl();
//	alert(cid);
    window.location.href=result+"/course/select?term="+term+"&cid="+cid;
}
